<?php
/**	
*	FILENAME: 		/libraries/users.php
*	DESCRIPTION:	This library contains and returns information related MyNova Mobile user records.
*	AUTHOR:			Casey Burkhardt
*	VERSION:		1.0.0
*	LAST MODIFIED:	12/31/2009
**/

require_once($_SERVER['DOCUMENT_ROOT'] . "/libraries/database.php");

/**	
*	DESCRIPTION:	Returns the `users`.`uid` value of a user record given an LDAP username.
**/
function getUserIDValue($ldapUsername) {
	connectToDatabase();
	$sql = "SELECT *
			FROM `users`
			WHERE `ldap_username` = '" . $ldapUsername . "';";
	$result = mysql_query($sql) or die(mysql_error());
	if (mysql_num_rows($result) > 0) {
		while ($row = mysql_fetch_assoc($result)) {
			return $row["uid"];
		}
	} else {
		return FALSE;
	}	
}

/**	
*	DESCRIPTION:	Returns the LDAP username of a user record given a `users`.`uid` value.
**/
function getLDAPUsername($uid) {
	connectToDatabase();
	$sql = "SELECT *
			FROM `users`
			WHERE `uid` = '" . $uid . "';";
	$result = mysql_query($sql) or die(mysql_error());
	if (mysql_num_rows($result) > 0) {
		while ($row = mysql_fetch_assoc($result)) {
			return $row["ldap_username"];
		}
	} else {
		return FALSE;
	}	
}
?>